import { defineStore } from 'pinia'
import type { RouteRecordRaw } from 'vue-router'


export interface SiteConfig {
  siteName: string
  recordNumber?: string
  version: string
  cdnUrl: string
  apiUrl: string
  upload: {
      mode: string
      [key: string]: any
  }
  headNav: RouteRecordRaw[]
  initialize: boolean
  userInitialize: boolean
}

export const useSiteConfig = defineStore('siteConfig', {
    state: (): SiteConfig => {
        return {
            siteName: '',
            recordNumber: '',
            version: '',
            cdnUrl: '',
            apiUrl: '',
            upload: {
                mode: 'local',
            },
            headNav: [],
            initialize: false,
            userInitialize: false,
        }
    },
    actions: {
        dataFill(state: SiteConfig) {
            this.$state = state
        },
        setHeadNav(headNav: RouteRecordRaw[]) {
            this.headNav = headNav
        },
        setInitialize(initialize: boolean) {
            this.initialize = initialize
        },
        setUserInitialize(userInitialize: boolean) {
            this.userInitialize = userInitialize
        },
    },
})
